<?php
			foreach($cropNames as $cropName){
				$result = $result . "<th>$cropName</th>";
			}
			
			$arrayOfSelectedAttributes = array();
			if ($_GET['amount_harvested'] == 'on') {
				$arrayOfSelectedAttributes[] = 'amount_harvested';
			}
			if ($_GET['amount_donated'] == 'on') {
				$arrayOfSelectedAttributes[] = 'amount_donated';
			}
			if ($_GET['sales'] == 'on') {
				$arrayOfSelectedAttributes[] = 'sales';
			}
			if ($_GET['number_planted'] == 'on') {
				$arrayOfSelectedAttributes[] = 'number_planted';
			}
			if ($_GET['seeds_bought'] == 'on') {
				$arrayOfSelectedAttributes[] = 'seeds_bought';
			}
			if ($_GET['pest_issues'] == 'on') {
				$arrayOfSelectedAttributes[] = 'pest_issues';
			}
			if ($_GET['weed_issues'] == 'on') {
				$arrayOfSelectedAttributes[] = 'weed_issues';
			}

			
			print "<form action=\"\">";
			print "<select id=\"selectForm\" onchange=\"changeAttribute(this.value)\" name=\"attributes\">";
			foreach ($arrayOfSelectedAttributes as $a) {
				print "<option value=\"" . $a . "\">" . $a . "</option>";
			}
			print "</select>";
			print "</form>";

			$result = $result . "</tr></thead><tbody>";
			
			$startMonthNum = substr($startDate,5,2); //gets start month number
			$endMonthNum = substr($endDate,5,2);
			$year = substr($startDate,0,4);
			
			for ($i = $startMonthNum; $i <= $endMonthNum; $i++) {
				$result = $result . "<tr><td><img id=\"".getMonth($i)."\" src=\"DataTables-1.7.3/details_open.png\" /></td><td>".getMonth($i)."</td>";
				$cropTracker = 0;
				foreach ($cropNames as $cropName) {
					if ($attrs[0] == 'sales') {
						if ($i == $startMonthNum) { //if it's the first month, start with startDate
							$result = $result . "<td>".getRangeData($startDate, $year."-$i-31", getCropId($cropName), $attrs[0], getUnitId($units[$cropTracker]), getCustomerId($_GET['customers'])) . "</td>";
						}
						elseif ($i == $endMonthNum) {
							$result = $result . "<td>".getRangeData($year."-$i-01", $endDate, getCropId($cropName), $attrs[0], getUnitId($units[$cropTracker]), getCustomerId($_GET['customers'])) . "</td>";
						}
						else{
							$result = $result . "<td>".getRangeData($year."-$i-01", $year."-$i-31", getCropId($cropName), $attrs[0], getUnitId($units[$cropTracker]), getCustomerId($_GET['customers'])) . "</td>";
						}
						$cropTracker += 1;
					}
					elseif ($attrs[0] == 'amount_donated') {
						if ($i == $startMonthNum) { //if it's the first month, start with startDate
							$result = $result . "<td>".getRangeData($startDate, $year."-$i-31", getCropId($cropName), $attrs[0], getUnitId($units[$cropTracker]), getCustomerId($_GET['donationCustomers'])) . "</td>";
						}
						elseif ($i == $endMonthNum) {
							$result = $result . "<td>".getRangeData($year."-$i-01", $endDate, getCropId($cropName), $attrs[0], getUnitId($units[$cropTracker]), getCustomerId($_GET['donationCustomers'])) . "</td>";
						}
						else{
							$result = $result . "<td>".getRangeData($year."-$i-01", $year."-$i-31", getCropId($cropName), $attrs[0], getUnitId($units[$cropTracker]), getCustomerId($_GET['donationCustomers'])) . "</td>";
						}
						$cropTracker += 1;
					}
					else {
						if ($i == $startMonthNum) { //if it's the first month, start with startDate
							$result = $result . "<td>".getRangeData($startDate, $year."-$i-31", getCropId($cropName), $attrs[0], getUnitId($units[$cropTracker])) . "</td>";
						}
						elseif ($i == $endMonthNum) {
							$result = $result . "<td>".getRangeData($year."-$i-01", $endDate, getCropId($cropName), $attrs[0], getUnitId($units[$cropTracker])) . "</td>";
						}
						else{
							$result = $result . "<td>".getRangeData($year."-$i-01", $year."-$i-31", getCropId($cropName), $attrs[0], getUnitId($units[$cropTracker])) . "</td>";
						}
						$cropTracker += 1;
					}
				}
				$result = $result . "</tr>";
			}
?>